package org.zeus.zipkin.client;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

@RestController
public class TestController {

    @Resource
    private RestTemplate restTemplate;

    @GetMapping(value = "/hello")
    public String hello() {
        return "hello";
    }

    @GetMapping(value = "/world")
    public String world() {
        return restTemplate.getForObject("http://zeus-eureka-client/hello", String.class);
    }

    @GetMapping("/json")
    public String json() {
        return "{\"_index\":\"zipkin-2018-08-15\",\"_type\":\"servicespan\",\"_id\":\"zeus-zipkin-client|http:/hello\",\"_version\":2,\"_score\":1,\"_source\":{\"serviceName\":\"zeus-zipkin-client\",\"spanName\":\"http:/hello\"}}";
    }

    @GetMapping("/exception")
    public String exception() {
        System.out.println(1 / 0);
        return null;
    }

}
